package cn.edu.ahpu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.ahpu.pojo.Formula;
import cn.edu.ahpu.pojo.Json;
import cn.edu.ahpu.service.ComputeService;

@Controller
public class PageController {
	
	@Autowired
	private ComputeService computeService;
	
	/**
	 * 根据请求返回对应页面
	 * @param pageName
	 * @return
	 */
	@RequestMapping("{pageName}")
	public String doPages(@PathVariable("pageName") String pageName) {
		System.out.println(pageName);
		return pageName;
	}
	
	//生成0~100算式
	@RequestMapping("doCreateZeroToHundred")
	@ResponseBody
	public Json doZeroToHundred() {
		List<Formula> list = computeService.createZeroToHundred();
		return new Json(list);
	}
	
	//生成0~100带括号算式
	@RequestMapping("doCreateWithBracket")
	@ResponseBody
	public Json doCreateWithBracket() {
		List<Formula> list = computeService.createWithBracket();
		return new Json(list);
	}
}
